//
//  YueViewController.m
//  YaDiuDiu
//
//  Created by 欧洪飞 on 2017/8/23.
//  Copyright © 2017年 jy. All rights reserved.
//

#import "YueViewController.h"

#import "ChonZhiViewController.h"
#import "TiXianViewController.h"
@interface YueViewController ()<UITableViewDelegate,UITableViewDataSource>{
    NSArray *array1;
    NSArray *array2;
}

@property (nonatomic,strong)UITableView *tableView;

@end

@implementation YueViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = COLOR_RGB(242, 242, 242, 1);
    [self showNav:@"我的余额"];
    
    array1 = @[@"充值",@"提现"];
    array2 = @[@"充值",@"余额-(2)"];
    
    [self loadUI];
    
}

- (void)loadUI{
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 64, ScreenWidth, 150)];
    view.backgroundColor = COLOR_RGB(54, 59, 61, 1);
    [self.view addSubview:view];
    
    UILabel *lab1 = [[UILabel alloc] init];
    lab1.text = @"账户余额(元)";
    lab1.textColor = [UIColor whiteColor];
    lab1.font = [UIFont systemFontOfSize:15.0];
    [view addSubview:lab1];
    [lab1 makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(16);
        make.top.equalTo(30);
    }];
    NSLog(@"price:%@",_price);
    UILabel *lab2 = [[UILabel alloc] init];
    lab2.text = _price;
    lab2.textColor = [UIColor whiteColor];
    lab2.font = [UIFont systemFontOfSize:50.0];
    [view addSubview:lab2];
    [lab2 makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(16);
        make.bottom.equalTo(-20);
    }];
    
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, view.frame.origin.y+view.frame.size.height+10, ScreenWidth, 44*2-1) style:UITableViewStylePlain];
    _tableView.dataSource = self;//44*10+60
    _tableView.delegate = self;
    _tableView.scrollEnabled = NO;
    [self.view addSubview:_tableView];
    
    UIImageView *imageview = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@""]];
    [self.view addSubview:imageview];
    [imageview makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view.centerX);
        make.bottom.equalTo(self.view.bottom).offset(-10);
    }];
    
    
}

#pragma -mark UITableViewDataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return array1.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellId = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellId];
    }
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.text = array1[indexPath.row];
    cell.textLabel.font = [UIFont systemFontOfSize:15.0];
    cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@",array2[indexPath.row]]];
    
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        ChonZhiViewController *chonzhi = [[ChonZhiViewController alloc] init];
        [self.navigationController pushViewController:chonzhi animated:YES];
    }else{
        TiXianViewController *tixian = [[TiXianViewController alloc] init];
        tixian.price = _price;
        [self.navigationController pushViewController:tixian animated:YES];
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
